package org.yu.register.capability;

import net.minecraft.nbt.CompoundTag;
import net.minecraftforge.common.util.INBTSerializable;

@SuppressWarnings("unused")
public class LingQi implements INBTSerializable<CompoundTag> {
   protected boolean unLocked =false;
   protected final LingQiStorage lingQiStorage;

    public LingQiStorage getLingQiStorage() {
        return lingQiStorage;
    }

    public LingQi(int capacity)
    {
        this(capacity, capacity, capacity, 0);
    }

    public LingQi(int capacity, int maxTransfer)
    {
        this(capacity, maxTransfer, maxTransfer, 0);
    }

    public LingQi(int capacity, int maxReceive, int maxExtract)
    {
        this(capacity, maxReceive, maxExtract, 0);
    }

    public LingQi(int capacity, int maxReceive, int maxExtract, int lingQi) {
        this.lingQiStorage = new LingQiStorage(capacity,maxReceive,maxExtract,lingQi);
    }
    public LingQi unlock(){
        this.unLocked=true;
        return this;
    }
    @Override
    public CompoundTag serializeNBT() {
        CompoundTag tag=new CompoundTag();
        tag.putBoolean("Unlocked", unLocked);
        tag.put("Storage",lingQiStorage.serializeNBT());
        return tag;
    }

    @Override
    public void deserializeNBT(CompoundTag nbt) {
        unLocked =nbt.getBoolean("Unlocked");
        if(nbt.contains("Storage"))
            lingQiStorage.deserializeNBT(nbt.get("Storage"));
    }
}
